<?php

error_reporting(E_ALL);

/**
 * untitledModel - class.ModeloUsr.php
 *
 * $Id$
 *
 * This file is part of untitledModel.
 *
 * Automatically generated on 27.11.2011, 19:02:44 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * include Conexion
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Conexion.php');

/* user defined includes */
// section 10-0-101-116-75074dcc:133e14e2698:-8000:000000000000178B-includes begin
// section 10-0-101-116-75074dcc:133e14e2698:-8000:000000000000178B-includes end

/* user defined constants */
// section 10-0-101-116-75074dcc:133e14e2698:-8000:000000000000178B-constants begin
// section 10-0-101-116-75074dcc:133e14e2698:-8000:000000000000178B-constants end

/**
 * Short description of class ModeloUsr
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ModeloUsr
    extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method getAllRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function getAllRows()
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017B7 begin
		$sql = "SELECT * FROM usuarios order by nivel asc";		
		return $this->ejecutarQuery($sql);
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017B7 end
    }

    /**
     * Short description of method getById
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function getById($id)
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017B9 begin       	
		$sql = "SELECT * FROM usuarios where iduser=".$id;		
		return $this->ejecutarQuery($sql);
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017B9 end
    }
	 public function SearchByEmail($correo)
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017B9 begin       	
		$sql = "SELECT * FROM usuarios where correo='".$correo."'";		
		return $this->ejecutarQuery($sql);
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017B9 end
    }

    /**
     * Short description of method InserRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function InserRow($datos)
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017BC begin
		$sql = "INSERT INTO usuarios (
			nombre,
			apellidos,
			fecha_nac,
			correo,
			contra
			) VALUES (
			'".$datos['nombre']."',
			'".$datos['apellidos']."',
			'".$datos['fecha_nac']."',
			'".$datos['correo']."',						
			'".$datos['contra']."'			
			)";
		$this->ejecutarQuery($sql);
		return mysql_insert_id();    	
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017BC end
    }

    /**
     * Short description of method UpdateRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function UpdateRow($datos)
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017BF begin
		$sql= "
			UPDATE usuarios SET 
				nombre = '".$datos['nombre']."',
				apellidos = '".$datos['apellidos']."',
				fecha_nac = '".$datos['fecha_nac']."',				
				correo = '".$datos['correo']."',				
				nivel = '".$datos['nivel']."'
				WHERE iduser = ".$datos['iduser']."
		";
		$this->ejecutarQuery($sql);        
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017BF end
    }

    /**
     * Short description of method DeleteRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function DeleteRows($id)
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017C2 begin
		$sql= "DELETE FROM usuarios WHERE iduser=".$id;
		$this->ejecutarQuery($sql);
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017C2 end
    }
	 public function Maestros()
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017C2 begin
		$sql1= "select * FROM usuarios WHERE nivel=2";
		$sql2= "select * FROM usuarios WHERE nivel=3";
		$arrayReturn[] =  $this->ejecutarQuery($sql1);
       	$arrayReturn[] =  $this->ejecutarQuery($sql2);
		return $arrayReturn;
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017C2 end
    }


} /* end of class ModeloUsr */

?>